<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title></title>
  <script src="../vue.js"></script>
</head>
<body>
  <div id="app">
    {{count}} {{doubleCount}} {{culCount(5)}}
    <div>
      {{title}}
      <button @click="handleClick">change title</button>
    </div>
  </div>
  <script>
    var app = new Vue({
      el: '#app',
      data: {
        count: 100,
        title: 'hello'
      },
      computed: {
        doubleCount() {
          // console.log('computed.')
          return this.count * 2
        },
        culCount() {
          return (num) => {
            // console.log(this.title)
            console.log(0)
            return this.count * num
          }
        }
      },
      methods: {
        change(num) {
          this.count = num
        },
        handleClick() {
          this.title = 'hello vue'
        }
      },
      mounted() {
        setTimeout(() => {
          this.change(500)
        }, 2000)
      },
      watch: {
        count: {
          handler(newValue) {
            document.title = newValue
          },
          immediate: true,
          deep: true
        }
      },
    })
  </script>
</body>
</html>